package sword.T61;

import java.util.Arrays;

/**
 * @Author: 18362
 * @Create: 2022-04-10 16:14:49 星期日
 */
class Solution {
    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int cnt = 0;
        for (int i=0; i<nums.length; ++i) {
            if (nums[i] == 0)
                cnt++;
            else
                break;
        }
        int last = nums[cnt];
        for (int i=cnt+1; i<nums.length; ++i) {
            while (nums[i] != last+1) {
                if (cnt > 0) {
                    last++;
                    cnt--;
                } else
                    return false;
            }
            last = nums[i];
        }
        return true;
    }
}
